<?php
/**
 * 等待配货更新异常订单的发货单状态。
 * 
 * @author liugang<liugang@shopex.cn>
 * @version 1.0
 */
error_reporting(E_ALL ^ E_NOTICE);
set_time_limit(600);

require_once(dirname(__FILE__) . '/../../lib/init.php');

$db = kernel::database();
$sql = "SELECT w.delivery_cost_actual,w.branch_id,w.delivery_id as wms_delivery_id,w.delivery_time,o.delivery_bn,o.delivery_id,w.outer_delivery_bn,w.weight FROM sdb_wms_delivery as w left join sdb_ome_delivery as o on w.outer_delivery_bn=o.delivery_bn WHERE w.status='3' AND o.process='false' limit 0,1000 ";

$deliverys = $db->select($sql); 
$deliveryObj = app::get('wms')->model('delivery');

foreach ($deliverys as $delivery){
	$dly_id = $delivery['wms_delivery_id'];
	$wms_id = kernel::single('ome_branch')->getWmsIdById($delivery['branch_id']);

	$data = array(
		'delivery_bn' => $delivery['outer_delivery_bn'],
		'delivery_time' => $delivery['delivery_time'],
		'weight' => $delivery['weight'],
		'delivery_cost_actual' => $delivery['delivery_cost_actual'],
		);
	$res = kernel::single('wms_event_trigger_delivery')->consign($wms_id, $data, false);
}

?>